<?php
/**
 * Created by PhpStorm.
 * User: 18048
 * Date: 2018/9/21
 * Time: 11:54
 */

header("Content-Type: text/html;charset=utf-8");

$serv = new swoole_server("0.0.0.0",9501);

$serv->on('connect',function($serv,$fd){
    echo "Client:connect.\n";
    $serv->send($fd,"用户:".$fd."已经成功连接上服务器");
});

$serv->on('receive',function($serv,$fd,$from_id,$data){
   $serv->send(1,"Server:".$data.$from_id);
});

$serv->on('close',function($serv,$fd){
    echo "Client:Close.\n";
});

$serv->start();

